package Controler;

import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;

import javax.swing.JTextField;

import Model.Model;

public class PersonalActionControler {
	

	
	public PersonalActionControler()
	{
		
	}
	
	public HashMap<String, JTextField> sendToHomePage(HashMap<String, JTextField> listTextFields)
	{
		if(Desktop.isDesktopSupported())
		{
			try {
				System.out.println(listTextFields.get(Model.HOMEPAGE).getText());
				if (listTextFields.get(Model.HOMEPAGE).getText().contains("http://"))
				{
					Desktop.getDesktop().browse(new URI(listTextFields.get(Model.HOMEPAGE).getText()));
				}
				else
				{
					String url = "http://" + listTextFields.get(Model.HOMEPAGE).getText();
					Desktop.getDesktop().browse(new URI(url));
				}
			} catch (IOException | URISyntaxException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}
		return listTextFields;
	}
}
